﻿using System;
using System.Linq;
using NUnit.Framework;
using ProjetoComperio.BusinessLogicLayer;
using ProjetoComperio.DataLayer.Entities;
using ProjetoComperio.Presentation.Web.Controllers;
using ProjetoComperio.Test.WebUI.FakeObjects;

namespace ProjetoComperio.Test.WebUI.Controllers
{
    [TestFixture]
    public class AcademicCoordinatorControllerTest
    {
        private AcademicCoordinatorController AcademicCoordinatorController;
        private AcademicCoordinatorBLL academicCoordinatorBLL;

        [SetUp]
        public void SetUp()
        {
            AcademicCoordinatorController = new AcademicCoordinatorController();
            AcademicCoordinatorController.ControllerContext = new FakeControllerContext(AcademicCoordinatorController);
            academicCoordinatorBLL = new AcademicCoordinatorBLL();

        }

        [Test]
        public void TestValidCreate()
        {
            var academicCoordinator = FillValidAcademicCoordinator();
            academicCoordinatorBLL.Create(academicCoordinator);
            Assert.IsTrue(academicCoordinatorBLL.RetrieveAcademicCoordinators().Any(ac => ac.Name.Equals(academicCoordinator.Name)));
        }

        private AcademicCoordinator FillValidAcademicCoordinator()
        {
            var academicCoordinator = new AcademicCoordinator();
            var currentDateTime = DateTime.Now;

            academicCoordinator.Name = "Higor Ramos" + currentDateTime.ToString();
            academicCoordinator.Email = "Higor@mail.com" + currentDateTime.ToString();
            academicCoordinator.BirthDate = DateTime.Now.AddYears(-20);
            academicCoordinator.Street = "Rua abcd";
            academicCoordinator.Neighbourhood = "Centro";
            academicCoordinator.ZipCode = "21223456";
            academicCoordinator.AddressNumber = "120";
            academicCoordinator.WebPage =  "www.higorcesar.com";
            academicCoordinator.Country = "Brasil";
            academicCoordinator.City = "Rio de Janeiro";
            academicCoordinator.State = "RJ";
            academicCoordinator.Enrollment ="0814700009" + new Random().Next().ToString();
            academicCoordinator.Description = "DSC";
            academicCoordinator.LattesPlatformWebPage = "LattesPlatformWebPage" + currentDateTime.ToString();
            academicCoordinator.AcademicOrganizationID = 1;
            academicCoordinator.EducationLevelID = 1;

            return academicCoordinator;
        }


        [Test]
        public void TestIndex()
        {
            AcademicCoordinatorController.Index();
        }

    }
}
